<!DOCTYPE html>
<html >
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>系统后台</title>

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/login.css">

    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.1.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/login.js"></script>
    <script src="__PUBLIC__/js/layer/layer.js" type="text/javascript"></script>
</head>
<body>

<div class="loginWrap">
    <div class="loginBody">
        <div class="loginHead">
            <ul>
                <li class="active"><a href="javascript:void(0)">系统后台</a></li>
                <li><a href="javascript:void(0)">网站后台</a></li>
                <span class="bgAnimate"></span>
            </ul>
        </div>
        <div class="loginToggle">
            <div class="loginForm">
                <form method="post" action="__ROOT__/index.php/Admin/Auth/login" id="enterpriseLoginForm">
                    <ul>
                        <li><span><img src="__PUBLIC__/images/userIcon.png">&nbsp;&nbsp;|&nbsp;&nbsp;</span><input type="text" class="inp" name="username" id="username" placeholder="用户名"></li>
                        <li><span><img src="__PUBLIC__/images/pswIcon.png">&nbsp;&nbsp;|&nbsp;&nbsp;</span><input type="password" class="inp" name="password" id="password" placeholder="密码"></li>
                    </ul>
                    <p class="subBtn"><input type="button" value="系统后台登录" id="btnSubmit" onclick="subEnterpriseLoginForm()"></p>
                </form>
            </div>
            <div class="loginForm hide">
                <form method="post" action="__ROOT__/index.php/Medium/Auth/login" id="governmentLoginForm">
                    <ul>
                        <li><span><img src="__PUBLIC__/images/userIcon.png">&nbsp;&nbsp;|&nbsp;&nbsp;</span><input type="text" class="inp" name="username" id="g_username" placeholder="用户名"></li>
                        <li><span><img src="__PUBLIC__/images/pswIcon.png">&nbsp;&nbsp;|&nbsp;&nbsp;</span><input type="password" class="inp" name="password" id="g_password" placeholder="密码"></li>
                    </ul>
                    <p class="subBtn"><input type="button" value="网站后台登录" ONCLICK="subGovernmentLoginForm()"></p>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    function subEnterpriseLoginForm()
    {
        var go = true;
        if($("#username").val() == '')
        {
            $("#username").focus();
            alert('请输入用户名');
            go = false;
            return false;
        }
        if($("#password").val() == '')
        {
            $("#password").focus();
            alert('请输入密码');
            go = false;
            return false;
        }
        if (go) {
            $.ajax({
                url: "__ROOT__/index.php/Admin/Auth/login",
                type: "post",
                data: $("#enterpriseLoginForm").serializeArray(),
                dataType: "json",
                success: function( result ){
                    console.log(result);
                    layer.closeAll();
                    if ( result.status == 0) {
                        window.location.href="__ROOT__/index.php/Admin/Advertising/index";
                    } else{
                        layer.alert(result.msg);
                    }
                },
                error:function()
                {
                    layer.closeAll();
                    layer.alert('页面出错，请刷新页面后重试');
                }
            });
            layer.load(2, {time: 10*1000});
        }
    }

    function subGovernmentLoginForm()
    {
        var go = true;
        if($("#g_username").val() == '')
        {
            $("#g_username").focus();
            alert('请输入用户名');
            go = false;
            return false;
        }
        if($("#g_password").val() == '')
        {
            $("#g_password").focus();
            alert('请输入密码');
            go = false;
            return false;
        }
        if (go) {
            $.ajax({
                url: "__ROOT__/index.php/Medium/Auth/login",
                type: "post",
                data: $("#governmentLoginForm").serializeArray(),
                dataType: "json",
                success: function( result ){
                    layer.closeAll();
                    if ( result.status == 0 ) {
                        window.location.href="__ROOT__/index.php/Medium/Index";
                    } else
                    {
                        layer.alert(result.msg);
                    }
                },
                error:function()
                {
                    layer.closeAll();
                    layer.alert('页面出错，请刷新页面后重试');
                }
            });
            layer.load(2, {time: 10*1000});
        }

    }
</script>

</body>
</html>


